<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!--style quản lý loại danh mục-->
<style>
	a.thua__link_1:link { font-size: 14px; text-decoration: none;  color: #0b55c4; }
	a.thua__link_1:visited { font-size: 14px; color: #0b55c4; text-decoration: none; }
	a.thua__link_1:hover { font-size: 14px; text-decoration: none; color: #084095;  font-style: normal; }
</style>
<?php 
	//lấy chuỗi tìm kiếm
	function tinh_chuoi_or()
	{
		$chuoi_or="";
		if($_GET['tu_khoa']=="Từ khóa tìm kiếm")
		{
			$tu_khoa_ccc="";
		}
		else 
		{
			$tu_khoa_ccc=$_GET['tu_khoa'];
		}
		$mang_tk__abc=explode(" ",$tu_khoa_ccc);
		for($f=0;$f<count($mang_tk__abc);$f++)
		{
			$q=$mang_tk__abc[$f];
			if($q!="")
			{
				$chuoi_or=$chuoi_or."ten like '%$q%' or ";
			}
		}
		if($chuoi_or!="")
		{
			$chuoi_or=substr($chuoi_or,0,-3);
			$chuoi_or=" and ( ".$chuoi_or." ) ";
		}
		return $chuoi_or;
	}
	//echo $chuoi_or."<hr>";
?>
<!--kịch bản chuyển link-->
<script type="text/javascript">
	function chuyen_link__ooo(id)
	{
		//alert(id);
		window.location="?thamso=quan_ly_san_pham&cap_do="+id;
	}
</script>

<?php 
	//tính số record trên 1 trang
	function tinh_so_trang($so_gioi_han)
		{
			$sql="select count(*) from dm_loai";
			$sql1=mysql_query($sql);
			$data=mysql_fetch_row($sql1);
			$st=ceil($data[0]/$so_gioi_han);
			return $st;
		}
	$ssp_td=1;
	$sd=10;
	$so_gioi_han=$ssp_td*$sd;
	if($_GET['trang']=="")
	{
		$vtbd=0;
	}
	else 
	{
		$vtbd=($_GET['trang']-1)*$so_gioi_han;
	}
	$st=tinh_so_trang($so_gioi_han);
?>
<!--Nút thêm loại danh mục-->
<a href="?thamso=themloai"><input type="button" value="Thêm loại máy" style="height:30px; width:200px"/></a>
<center>
  <table width="990px" border="1" style="margin-top:6px" id="er">
  <tr>
			<td width="100" align="center"><b>Mã Loại</b></td>
			<td width="538" align="center"><b>Tên Loại</b></td>
            <td width="161" align="center"><b>Sửa</b></td>
			<td width="163" align="center"><b>Xóa</b></td>
		</tr>
		<?php 
			$sql="select * from dm_loai order by maloai asc limit $vtbd,$so_gioi_han";
			$sql1=mysql_query($sql);
			while($tv_2=mysql_fetch_array($sql1))
			{
				$link_sua="?thamso=sual&id=".$tv_2['maloai'];
				$link_xoa="?thamso=xoal&id=".$tv_2['maloai'];
				?>
					<tr>
						<td align="center" >
							<a href="<?php echo $link_sua; ?>" class="thua__link_1">
								<?php echo $tv_2['maloai']; ?>
							</a>
                            <input type="hidden" name="idh_cc" value="<?php echo $tv_2['maloai']; ?>" />
						</td>
						<td align="center" >
						<?php echo $tv_2['tenloai']; ?></td>
						<td align="center">
							<a href="<?php echo $link_sua; ?>" class="sua_xoa" >
								Sửa
							</a>
						</td>
						<td align="center">
							<a href="<?php echo $link_xoa; ?>" class="sua_xoa" >
								Xóa
							</a>
						</td>
					</tr>
				<?php
			}
		?>
		
	</table>
          		<?php
			echo "<div id='trang'>";
		for($i=1;$i<=$st;$i++)
		{
			$link="?thamso=loai&trang=$i";
			echo "<a href='$link' class='hello'><font size='4px'>";
			echo $i;
			echo "</font></a>";echo"  ";
		}
	echo "</div>";
		?>
        <div style="height:10px"></div>
</center>
<script>
	table_css_2("er");
</script>